home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / LONGJMP.S < prev    next >
Text File  |  1992-03-02  |  1KB  |  46 lines

  1. /* This is file LONGJMP.S */
  2. /*
  3. ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14.  
  15. /*
  16. **    jmp_buf:
  17. **     eax ebx ecx edx esi edi ebp esp eip
  18. **     0   4   8   12  16  20  24  28  32
  19. */
  20.  
  21.     .globl    _longjmp /* jmp_buf, int */
  22. _longjmp:
  23.     pushl    %ebp
  24.     movl    %esp,%ebp
  25.  
  26.     movl    8(%ebp),%edi    /* get jmp_buf */
  27.     movl    12(%ebp),%eax    /* store retval in j->eax */
  28.     movl    %eax,0(%edi)
  29.  
  30.     movl    24(%edi),%ebp
  31.  
  32.     cli
  33.     movl    28(%edi),%esp
  34.     
  35.     pushl    32(%edi)    /* for a ret! */
  36.  
  37.     movl    0(%edi),%eax
  38.     movl    4(%edi),%ebx
  39.     movl    8(%edi),%ecx
  40.     movl    12(%edi),%edx
  41.     movl    16(%edi),%esi
  42.     movl    20(%edi),%edi
  43.     sti
  44.  
  45.     ret            /* actually jump to new eip */
  46.